
var main = function() {
    console.log('DOM Loaded!');
    let bts = document.getElementsByClassName('bt');
    let onClick = function(event) {
        let button = event.currentTarget;
        let offsetX = event.offsetX - button.offsetWidth/2;
        let wave = button.querySelector('.wave');
        wave.style.setProperty('left',offsetX+'px');
        wave.classList.add('animat-bigger');
        button.classList.add('clicked');
        wave.addEventListener("animationend", (e)=>{
            e.currentTarget.classList.remove('animat-bigger');
            button.classList.remove('clicked');
        });
    };
    for (let idx = 0; idx < bts.length; idx++) {
        const bt = bts[idx];
        bt.addEventListener('click',onClick);
    }
};

window.addEventListener('DOMContentLoaded', main);
